import { StorageKeys } from '@/enums/storage'
import { uniEvent } from '@/enums/uniEvent'

export const getToken = () => uni.getStorageSync(StorageKeys.登录凭证) as string
export const setToken = (token: string) => {
  uni.setStorageSync(StorageKeys.登录凭证, token)
  uni.setStorageSync(StorageKeys.登录标志, true)
  uni.$emit(uniEvent.登录成功)
}

export interface LocationInfo {
  longitude: string | number
  latitude: string | number
  city?: string
  timer: number
}
export interface navInfo {
  statusBarH: number
  customBarH: number
}
export const getLocationInfo = () => uni.getStorageSync(StorageKeys.位置信息) as LocationInfo
export const setLocationInfo = (v: LocationInfo) =>
  uni.setStorageSync(StorageKeys.位置信息, v)
export const removeLocationInfo = () => uni.removeStorageSync(StorageKeys.位置信息)

export const setNavbarHeihgt = (v: navInfo) => uni.setStorageSync(StorageKeys.导航栏高度, v)
export const getNavbarHeihgt = () => uni.getStorageSync(StorageKeys.导航栏高度) as navInfo
